package servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import entity.Course;
import entity.Elective;
import service.ISmsserivce;
import service.impl.SmsserivceImpl;

/**
 * Servlet implementation class StudentAddServlet
 */
@WebServlet(asyncSupported = true, urlPatterns = { "/TeacherSelectAllServlet" })
public class TeacherSelectAllServlet extends HttpServlet {
	
	private ISmsserivce smsservice = new SmsserivceImpl();
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html; charset=UTF-8");
		
		HttpSession session = request.getSession();
		
		try {
			
			List<Course> teacherAll = smsservice.selectAll();
			
			if(teacherAll !=null) {
				session.setAttribute("teacherAll", teacherAll);
				response.sendRedirect("Teachertable.jsp");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		doGet(request, response);
	}

}
